<template>
  <div class="box">
    <nav-bra></nav-bra>

    <empty v-if="empty"></empty>
    <div v-else>
      <Address></Address>
      <cart-list></cart-list>
    </div>

    <divider></divider>
    <recommend-list></recommend-list>
  </div>
</template>

<script>
import Empty from "../components/Cart/Empty.vue";
import NavBra from "../components/Cart/NavBra.vue";
import CartList from "../components/Cart/CartList.vue";

import { getCart } from "../apis/cart";
import Divider from "../components/Cart/divider.vue";
import RecommendList from "../components/Cart/recommendList.vue";
import Address from "../components/Cart/Address.vue";

export default {
  components: { NavBra, Empty, CartList, Divider, RecommendList, Address },
  // name: '我的Cart',

  data() {
    return {
      empty: true,
    };
  },

  mounted() {},
  created() {
    if (!localStorage.getItem("token")) {
      this.$router.push("/login");
    } else {
      getCart({ userid: localStorage.getItem("userid") }).then((data) => {
        // console.log(data.data.code)
        if (data.data.code == "10020") {
          this.empty = true;
        } else {
          this.empty = false;
          // console.log(this.empty)
        }
      });
    }
  },
  methods: {},
};
</script>

<style scoped>
div {
  /* position:absolute; */
  flex: 1;
}
</style>